﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using TomNet.AspNetCore.Mvc.Filters;

namespace TomNet.AspNetCore.Mvc
{
    /// <summary>
    /// WebApi控制器基类
    /// </summary> 
    [ApiController]
    [Route("[controller]")]
    public abstract class ApiControllerBase : ControllerBase
    {
        /// <summary>
        /// 获取或设置，日志对象 
        /// 注意，它可不能出现在构造函数里，想用在构造函数中，请参考底层方法
        /// </summary>
        protected ILogger Logger => HttpContext.RequestServices.GetLogger(GetType());
        protected IHeaderDictionary Headers => HttpContext.RequestServices.GetHeaders();
    }
}
